import { getToken } from '@/utils/auth'

const state = {
  token: getToken(),
  user: JSON.parse(localStorage.getItem('user')) || {}
}

const mutations = {
  SET_TOKEN: (state, token) => {
    state.token = token
  },
  SET_USER: (state, user) => {
    localStorage.setItem('user', JSON.stringify(user))
    state.user = user
  }
}

const actions = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
